import 'package:flutter/material.dart';

import '../main/main_page.dart';

/// FileName next_page
///
/// @Author lax
/// @Date 2024/6/3
///
/// @Description

class NextPage extends StatefulWidget {
  final int page;

  const NextPage({super.key, required this.page});

  @override
  State<StatefulWidget> createState() {
    return _NextPageState();
  }
}

class _NextPageState extends State<NextPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: TextButton(
          onPressed: () {
            Navigator.pop(context);
          },
          child: const Icon(Icons.arrow_back_ios),
        ),
        title: Text('第${widget.page}页'),
        centerTitle: true,
        backgroundColor: Colors.lightGreen,
      ),
      body: body(),
    );
  }

  Widget body() {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          TextButton(
            onPressed: () {
              Navigator.pop(context);
            },
            child: const Text('上一页', textScaleFactor: 1.5),
          ),
          TextButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (_) {
                  return NextPage(page: widget.page + 1);
                }),
              );
            },
            child: const Text('下一页', textScaleFactor: 1.5),
          ),
        ],
      ),
    );
  }
}
